<!--
  ~ Copyright (C) 2019 Baidu, Inc. All Rights Reserved.
  -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta name="format-detection" content="telephone=no">
    <meta content="telephone=no" name="format-detection">
    <meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge"/>
    <link rel="stylesheet" media="screen and (max-width:900px)" href="/assets/stylesheets/style_wap.css"
          type="text/css"/>
    <link rel="stylesheet" media="screen and (min-width:900px)" href="/assets/stylesheets/style_pc.css" type="text/css"/>
    <title>会员补货</title>
</head>
<body>
<!-- 前端嵌套写法，仅供前端使用，首页有完整代码 -->
<div class="topline" id="J_topline" data-til="会员补货">
    <nav th:replace="hjh/include::menuV"></nav>
</div>
<div class="vipreg tixian content">
    <p class="fgtil">会员升级为代理</p>
    <div class="formline">
        <div class="fline"><p class="ado">会员级别：</p>
            <p class="flinete"><span class="fc fsa"
                                     th:text="${memberLevel}"></span></p>
        </div>
        <div class="fline"><p class="ado">推荐代理人：</p>
            <input class="J_ctrol ctrolwa ctrol" data-target="jiedian"
                   data-provide="typeahead" type="text" placeholder="推荐代理人"
                   name="superior" id="J_reco" th:value="${superior}">
        </div>
        <div class="fline"><p class="ado">升级代理价格：</p>
            <p class="flinete"><span class="fc fsa"
                                     th:text="${price}"></span>元</p>
        </div>
        <div class="fline linea"><a href="javascript:;" class="btn fbtm" id="J_btn">提交</a></div>
    </div>
</div>
<nav th:replace="hjh/include::bottomV"></nav>
<script language="javascript" type="text/javascript" src="/assets/javascript/jquery-2.1.4.min.js"></script>
<script language="javascript" type="text/javascript" src="/assets/javascript/func.js"></script>
<script type="text/javascript">
    $(function () {
        // $("#J_reco").typeahead({
        //     insertPoint:$("#J_reco"),
        //     source: function (query, process) {
        //         $.get('/search_user?keyword=' + query + "&findChildren=1", "", function (data) {
        //             process(data);
        //         })
        //     }
        // });

        var J_btn = $('#J_btn'),
            isajax = false, // 设置开关
            data = {"superior": ""};
        J_btn.click(function () {
            //ajax提交数据
            //alert('提交的数据：'+JSON.stringify(data));
            isajax = true;
            J_btn.html("正在提交···");
            data.superior = $("#J_reco").val();
            $.ajax({
                type: "POST",
                url: "/upgrade?v=" + (new Date().getTime()),
                data: JSON.stringify(data),
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    if (res.code == 0) {
                        // 提交成功
                        alert('升级申请提交成功');
                        window.location.href = '/pay?id='+res.domain;
                    } else {
                        errormsg($('#J_amount'), res.msg);
                        J_btn.html("提交");
                    }
                    ;
                },
                complete: function () {
                    isajax = false;
                }
            });

        });
    });
</script>
</body>
</html>
